<template>
	<view class="shopDetail">
		<view class="name">{{db.name}}</view>
		<view class="time">{{db.createtime}}</view>
		<!-- <view v-html="db.content" class="content"></view> -->
		<view v-html="$options.filters.formatRichText(db.content)" class="content"></view>
		
		<view class="submit" @click="C_submit">点击报名</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				db:{}
			};
		},
		filters: {
		    formatRichText(html) { //控制小程序中图片大小
		    let newContent = ''
		    newContent = html.replace(/<img[^>]*>/gi,
		    	function(match) {
		    		match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
		    		match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
		    		match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
		    		return match;
		    	});
		    newContent = newContent.replace(/style="[^"]+"/gi,
		    	function(match) {
		    		match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
		    			'max-width:100%;');
		    		return match;
		    	});
		    newContent = newContent.replace(/<br[^>]*\/>/gi, '');
		    newContent = newContent.replace(/\<img/gi,
		    	'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
		    return newContent;
		    }
		},
		onLoad(o) {
			this.db = JSON.parse(decodeURIComponent(o.db))
			// let JKgoodinfo = await this.$u.api.JKgoodinfo({goods_id:o.id})
			// console.log(JKgoodinfo,'JKgoodinfo');
		},
		methods:{
			C_submit(){
				// 这里需要判断时候已授权
				uni.navigateTo({
					url:'/pages/binduserinfo/binduserinfo?id='+this.db.id
				})
			}
		}
	}
</script>

<style lang="scss">
	page{background-color: #FFFFFF;}
	.shopDetail{
		padding: 30rpx ;
		.name{
			font-size: 40rpx;
			font-weight: bold;
		}
		.time{
			margin: 30rpx 0 50rpx;
		}
		.submit{
			text-align: center;
			padding: 20rpx;
		}
	}
</style>
